/*
 * Created on Feb 6, 2005
 * Created by dfhuynh
 */
package edu.mit.simile.longwell.schema;

import java.util.Set;
import java.util.SortedSet;

import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;

import edu.mit.simile.longwell.IStructuredModel;


/**
 * @author dfhuynh
 */
public interface ISchemaModel extends IStructuredModel {
	static public class LabeledObject {
		final public RDFNode	m_object;
		final public String		m_label;
		
		public LabeledObject(RDFNode object, String label) {
			m_object = object;
			m_label = label;
		}
		
		public RDFNode getObject() {
			return m_object;
		}
		
		public String getLabel() {
			return m_label;
		}
		
		public boolean isLiteral() {
			return m_object instanceof Literal;
		}
	}
	
	static public class PropertyValuePair {
		final public LabeledObject	m_property;
		final public SortedSet		m_values;
		final public boolean		m_isLikelyLiteral;
		
		public PropertyValuePair(LabeledObject property, SortedSet values, boolean isLikelyLiteral) {
			m_property = property;
			m_values = values;
			m_isLikelyLiteral = isLikelyLiteral;
		}
		
		public LabeledObject getProperty() {
			return m_property;
		}
		
		public SortedSet getValues() {
			return m_values;
		}
		
		public boolean isLikelyLiteral() {
			return m_isLikelyLiteral;
		}
	}
	
	/**
	 * Answer all things considered objects in this model.
	 * 
	 * @return
	 */
	public Set getAllObjects();
	
	/**
	 * Answer all structured schemas.
	 * 
	 * @return
	 */
	public Set getStructuredSchemas();
	
	/**
	 * Answer the structured schema with the given URI.
	 * 
	 * @param uri
	 * @return
	 */
	public IStructuredSchema getStructuredSchema(String uri);
	
	/**
	 * Answer the structured class named by the given resource.
	 * 
	 * @param resource
	 * @return
	 */
	public IStructuredClass getStructuredClass(Resource resource);
	
	/**
	 * Answer the structured property corresponding to the given RDF property.
	 * 
	 * @param property
	 * @return
	 */
	public IStructuredProperty getStructuredProperty(Property property);
	
	/**
	 * Guess all the schemas that the given resource belongs to.
	 * 
	 * @param uri
	 * @return
	 */
	public Set guessSchemasOfResource(Resource resource);
	
	/**
	 * @param resources
	 * @return
	 */
	public Set getClassesOfResources(Set resources);
	
	/**
	 * Answer the set of structured properties that the given objects share.
	 * 
	 * @param objects
	 * @return
	 */
	public SortedSet getSortedStructuredProperties(Set objects);
	
	/**
	 * Convert the resource, which might be anonymous, to a pseudo URI.
	 * 
	 * @param r
	 * @return
	 */
	public String resourceToPseudoURI(Resource resource);
	
	/**
	 * Concert a pseudo URI to a resource, which can be anonymous.
	 * 
	 * @param pseudoURI
	 * @return
	 */
	public Resource pseudoURIToResource(String pseudoURI);
	
	
	/**
	 * Answer the label of a resource.
	 * 
	 * @param r
	 * @param model
	 * @param locale
	 * @param abbreviate
	 * @return
	 */
	public String getLabel(Resource r, String locale, boolean abbreviate);
	
	/**
	 * Answer all the types of the given resource that have no parent type 
	 * among themselves.
	 * 
	 * @param r
	 * @param model
	 * @return
	 */
	public Set getYoungestTypes(Resource r, Model model);
	
	/**
	 * Return a sorted set of PropertyValuePair's. forward indicates direction
	 * of links.
	 * 
	 * @param r
	 * @param locale
	 * @param forward
	 * @return
	 */
	public SortedSet getPropertyValuePairs(Resource r, String locale, boolean forward);
}